import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import service.AirlineReservationServiceProxy;
import bean.Employee;
import constants.AirlineReservationServiceConstants;


public class ListEmployeesServlet extends HttpServlet{
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		
		
		AirlineReservationServiceProxy proxy = new AirlineReservationServiceProxy(
				AirlineReservationServiceConstants.SERVICE_URL);
		Employee[] employees = proxy.listEmployees();
		List<Employee> lstEmployees = new ArrayList<Employee>();
		
		
		
		if(employees!= null)
			lstEmployees = Arrays.asList(employees);
		
		System.out.println("-Inside List Employees---------------------"+(String)req.getAttribute("from"));
			
		req.setAttribute("from", (String)req.getAttribute("from"));
		req.setAttribute("lstEmployees", lstEmployees);
		req.getRequestDispatcher("listEmployee.jsp").forward(req, resp);
			
			
			
		
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(req, resp);
	}
}
